package com.tian.system.controller;

import java.util.List;

import com.tian.common.core.controller.BaseController;
import com.tian.common.core.domain.AjaxResult;
import com.tian.common.core.page.TableDataInfo;
import com.tian.system.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.tian.system.service.IUserService;

/**
 * 用户表 信息操作处理
 *
 * @author zcx
 * @date 2019-12-09 15:30:35
 */
@Controller
@RequestMapping("/system/user")
public class UserController extends BaseController {
    private String prefix = "system/user";

    @Autowired
    private IUserService userService;

    /**
     * 查询用户表列表
     */
    @PostMapping("/page")
    @ResponseBody
    public TableDataInfo page(User user) {
        startPage();
        List<User> list = userService.selectUserList(user);
        return getDataTable(list);
    }

    /**
     * 新增保存用户表
     */
    @PostMapping("/add")
    @ResponseBody
    public String addSave(User user) {
        return toAjax(userService.insertUser(user));
    }

    /**
     * 修改保存用户表
     */
    @PostMapping("/edit")
    @ResponseBody
    public String editSave(User user) {
        return toAjax(userService.updateUser(user));
    }

    /**
     * 删除用户表
     */
    @PostMapping("/remove")
    @ResponseBody
    public String remove(int id) {
        return toAjax(userService.deleteUserById(id));
    }

    /**
     * 删除用户表
     */
    @PostMapping("/removes")
    @ResponseBody
    public String removes(String ids) {
        return toAjax(userService.deleteUserByIds(ids));
    }

}
